#!/usr/bin/python
# -*- coding:utf-8 -*-
# -------------------------------------------------------
# @author  : 龍皓
# @time    : 2025/2/25 21:55
# @function: the script is used to do something.
# @version : 1.0.0
# -------------------------------------------------------

# ui/data_panel.py
import pandas as pd
from PyQt6.QtCharts import QChart, QChartView, QPieSeries


class SalaryPieChart(QChartView):
    def __init__(self, data):
        series = QPieSeries()
        df = pd.DataFrame(data)
        salary_ranges = df['salary'].value_counts()

        for rng, count in salary_ranges.items():
            slice = series.append(rng, count)
            slice.setLabelVisible(True)

        chart = QChart()
        chart.addSeries(series)
        chart.setTitle("薪资分布")
        super().__init__(chart)